home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
178_01
/
tvx_cfg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-16
|
17KB
|
629 lines
/* ------------------------------- tvx_cfg.c ------------------------ */
#include "tvx_defs.ic"
#define BL remark("")
char synofr[20] = /* from table */
{' ',13,']',000,000,000,000,000,000,000,00,00,00,00,00,00,00,00,00,00};
char synoto[20] = /* translate to table */
{'r','d','{',00,000,0,000,00,00,000,00,00,00,00,00,00,00,00,00,00};
char funkey = 0; /* leading char for function key */
char funchar[50] = /* code sent by function key */
{
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
};
char funcmd[50] = /* equivalent command */
{
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
};
/* define standard command set */
char lexsym[LEXVALUES+1] = { E0, 'r', 'l', 'd', 'u',
4, 21, 8, 'k', 'i', 11, '"', '\'', ',', '.', 'f', 6, 'p',
'b', 'e', 2, 'v', 'o', '/', 's', 'g', 23, 25, 24, ';', '&',
'm', ':', '=', 7, 9, '{', 'a', 16, '?', 'h', 20, 'c', 'j', 't',
'n', 14, 15, 5, 18, '#', '*', '(', ')' };
char newlex[LEXVALUES+1] ;
char autoin, dsplin, scroll, xcases, warplm, wildch, funesc;
char rp[80];
FILE *f, *fopen();
main()
{
FAST int i, val;
cls();
remark("TVX define a configuration file -- Version 11/12/85");
BL;
for (;;)
{
prompt("Enter name of file to save configuration in: ");
reply(rp,79);
if ((f = fopen(rp,FILEWRITE)) == 0)
continue;
else
break;
}
remark("Standard commands settable by this program:");
BL;
remark("Commands (n => count allowed):");
remark("nA Append lines B Buff begin ^B File begin nC Change chrs nD Down");
remark("n^D Down column E Buff end nF Find ^F Find-file G Get save buf");
remark("^G Unkill nH Half page nI Insert J Jump back nK Kill ch");
remark("n^K Kill line nL Left M Mem stat nN Note loc n^N Reset loc");
remark("nO Open line nP Page ^P Print screen ^Q Quit nR Right");
remark("nS Save lines ^S Read file nT Tidy ^T Abort nU Up");
remark("n^U Up column V Verify n^W Write buff nBS Del ch n; Re-Find");
remark(" / Delete last = Change last ' Del ln beg \" Del ln end , Ln beg");
remark(" . Line end nTAB Word rt n{ Word left n& Rpt agn");
remark("? Help * Ins find pat n:p Set param p ^O Op. System");
remark("n^E Edit rptbuf ^R Restore rpt n#k Execute rpt n k times");
remark("Note: <> repeat, @ command file, and ESCAPE cannot be changed.");
BL;
for (;;)
{
BL;
prompt("Use standard command definitions? (y/n) ");
lreply(rp,10);
if (*rp == 'y')
{
for (i=0 ; i <= LEXVALUES ; ++i)
fputc(lexsym[i],f); /* write to file */
goto LEXDONE;
}
else if (*rp == 'n')
break;
}
CAGAIN:
cls();
remark("You now must re-define all 47 commands. You may simply enter");
remark("the key of the command (followed by a RETURN), or the decimal");
remark("code of the key, followed by a RETURN.");
BL;
/* define new commands */
for (i=0 ; i <= LEXVALUES ; ++i)
newlex[i] = 0; /* clear */
set(1,"cursor right (r)");
set(2,"cursor left (l)");
set(3,"cursor down (d)");
set(4,"cursor up (u)");
set(5,"cursor down in col (^d)");
set(6,"cursor up in col (^u)");
set(7,"del prev char (backspace)");
set(8,"kill character (k)");
set(9,"enter insert mode (i)");
set(10,"kill a line (^k)");
set(11,"delete to end of line (\")");
set(12,"delete to beginning of line (')");
set(13,"cursor to beginning of line (,)");
set(14,"cursor to end of line (.)");
set(15,"find (f)");
set(16,"find across buffer (^f)");
set(17,"scroll screen one page (p)");
set(18,"beginning of buffer (b)");
set(19,"end of buffer (e)");
set(20,"beginning of file (^b)");
set(21,"verify screen (v)");
set(22,"open line (o)");
set(23,"delete last thing (/)");
set(24,"save line in save buff (s)");
set(25,"get save buffer (g)");
set(26,"write buffer (^w)");
set(27,"save external file in save buffer (^y)");
set(28,"exit (^x)");
set(29,"find again (;)");
set(30,"execute repeat buffer (&)");
set(31,"memory status line (m)");
set(32,"set parameter (:)");
set(33,"delete last thing, enter insert (=)");
set(34,"get back last killed line (^g)");
set(35,"word rigth (tab)");
set(36,"word left ({)");
set(37,"append line to save buffer (a)");
set(38,"print screen (^p)");
set(39,"help (?)");
set(40,"scroll page half screen (h)");
set(41,"abort edit session (^t)");
set(42,"change characters (c)");
set(43,"jump back (j)");
set(44,"tidy (fill to margin) (t)");
set(45,"note position (n)");
set(46,"return to noted position (^n)");
set(47,"'push' to operating system (^O)");
set(48,"Edit repeat buffer (^E)");
set(49,"Restore repeat buffer (^R)");
set(50,"Execute repeat buffer k (#)");
set(51,"Insert last find match (*)");
cls();
remark("Commands have been defined. You can start over if you made any mistakes.");
remark("");
prompt("Are they ok? (y/n) ");
lreply(rp,10);
if (*rp == 'n')
goto CAGAIN;
for (i=0 ; i <= LEXVALUES ; ++i)
{
fputc(newlex[i],f); /* write to file */
lexsym[i] = newlex[i];
}
LEXDONE:
syno();
funkeys();
cls();
prompt("Use autoindent (n default) (y/n): ");
lreply(rp,10);
if (*rp == 'y')
fputc(1,f);
else
fputc(0,f);
BL;
prompt("Home display line: (1-66, 16 default): ");
rdint(&val);
if (val > 66 || val <= 0)
fputc(16,f);
else
fputc(val,f);
BL;
prompt("Scroll window (0 default): ");
rdint(&val);
if (val > 24)
val = 0;
fputc(val,f);
BL;
prompt("Find case (e=exact,a=any, any default): ");
lreply(rp,10);
if (*rp == 'e')
fputc(1,f);
else
fputc(0,f);
BL;
prompt("Auto line wrap width (0 default): ");
rdint(&val);
if (val > 79)
val = 0;
fputc(val,f);
BL;
prompt("Use wild cards (y default) (y/n)? ");
lreply(rp,10);
if (*rp == 'n')
fputc(0,f);
else
fputc(1,f);
BL;
prompt("Use BACKUP.LOG file (n default) (y/n)? ");
lreply(rp,10);
if (*rp == 'y')
fputc(1,f);
else
fputc(0,f);
#ifdef MSDOS
BL;
remark("The editor can recognize Ctrl-z as EOF, or it can ignore ^Z and");
remark("just use the standard MS-DOS end of file mark.");
prompt("Should the editor recognize Ctrl-Z as EOF? (y/n) ");
lreply(rp,10);
if (*rp == 'y')
fputc(1,f);
else
fputc(0,f);
#endif
cls();
remark("Configuration file created.");
fclose(f);
}
/* ===============================>>> FUNKEYS <<<========================*/
funkeys()
{
FAST int j,i,val;
SLOW int fun;
FAGAIN:
cls();
remark("You may now define up to 49 function keys to be translated to");
remark("commands OR letters. This translation will take place before");
remark("the editor gets the character at any level -- thus the translation");
remark("will apply equally to command mode and insert mode. The translation");
remark("assumes each function key generates a 2 character sequence. The");
remark("first character is an 'escape' character that must be the same for");
remark("each key. If the 'escape' character is really ESC, then you must");
remark("also define one function key to have ESC as its translat